package com.googlecode.autopp.driver;

import java.awt.Color;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Date;

/**
 * Driver which generates constant data.
 */
public class ConstDriver extends SimpleGenericDriver {

    @Override
    public boolean getBoolean() {
        return true;
    }

    @Override
    public Color getColor() {
        return Color.RED;
    }

    @Override
    public Date getDate() {
        return new Date(0);
    }

    @Override
    public double getDouble() {
        return 1.0;
    }

    @Override
    public float getFloat() {
        return 1.0f;
    }

    @Override
    public int getInteger() {
        return 1;
    }

    @Override
    public long getLong() {
        return 1;
    }

    @Override
    public byte getByte() {
        return 1;
    }

    @Override
    public String getString() {
        return "foo";
    }

    @Override
    public URI getURI() {
        try {
            return new URI("localhost");
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Cannot create URI object.", e);
        }
    }

    @Override
    public URL getURL() {
        try {
            return new URL("http://localhost");
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("Cannot create URL object.", e);
        }
    }

    @Override
    public Enum<?> getEnum(Class<Enum<?>> enumClass) {
        Enum<?>[] tab = enumClass.getEnumConstants();
        return tab.length > 0 ? tab[0] : null;
    }
}
